<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
 <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
 <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:set var="path" value="${pageContext.request.contextPath }" />
		
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<jsp:include page="/WEB-INF/pages/qtop.jsp" flush="true"></jsp:include>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>在线问答系统</title>
</head>
<body style="background-color: white;">
	<div style="padding: 0px 200px 10px">
		<h3>今天，你在开发时遇到了什么问题呢？<h3>
		<form method="post" >
			<button type="button" onclick="tques()" class="btn btn-success">我要提问</button>
		</form>
	</div>
	<div style="padding: 0px 200px 10px">
		<ul id="myTab" class="nav nav-tabs">
			<li class="active">
				<a href="#news" data-toggle="tab">
				最新的
				</a>
			</li>
			<li>
				<a href="#nojj" data-toggle="tab">待解决的
				</a>
			</li>
			<li class="dropdown">
				<a href="#isok"  data-toggle="tab">已解决的
				</a> 
			</li>
		</ul>
		<div id="myTabContent" class="tab-content">
			<div class="tab-pane fade in active" id="news">
		
	<div class="container">           
      <table class="table"  style="width:70% height:20px ">
	      <c:forEach items="${questions}" var="ques" varStatus="st">
			<tr>
			  <td class="col-md-1">	
				<dl>
				  <dt>${ques.acount}</dt>
				  <dd>回答</dd>
				</dl>
			  </td>
			  <td class="col-md-1">	
				<dl>
				  <dt>${ques.ccount}</dt>
				  <dd>收藏</dd>
				</dl>
			  </td>
			  <td class="col-md-8">
				<dl>
				  <dt><a href="" style="color: green; font-size: 8px;">${ques.uName}</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="" style="color: #0ccccc;font-size: 8px;"><fmt:formatDate value="${ques.qApplytime}" pattern="yyyy-MM-dd HH:mm:ss"/>提问</a></dt>
				  <dd><h4 class="title"><a href="${path}/ques/answerques/${ques.qId}" style="font-size: 24px;font-weight: bold;">${ques.qTitle}</a></dd>
				</dl>
			  </td>
			</tr>
		  </c:forEach>
	  </table>
	  	<c:if test="${pages.total eq 0}">
	  		没有数据
	 	</c:if>
	 	<c:if test="${pages.total ne 0}">
	 		${pages.total}条记录${pages.inpage}/${pages.totalpage}页&nbsp;
	 		<a href="">首页</a>
	 		<c:if test="${pages.inpage eq 1}"> <span>&nbsp;上一页&nbsp;</span></c:if>
	 		<c:if test="${pages.inpage ne 1}">&nbsp;<a href="">上一页</a>&nbsp;</c:if>
	 		<c:if test="${pages.inpage eq pages.totalpage}"><span>&nbsp;下一页&nbsp;</span></c:if>
	 		<c:if test="${pages.inpage ne pages.totalpage}">&nbsp;<a href="">下一页</a>&nbsp;</c:if>
	 		&nbsp;<a href="">末页</a>
	 	</c:if>
	</div>

			</div>
			<div class="tab-pane fade" id="nojj">
				<div class="container">           
			      <table class="table"  style="width:70% height:20px ">
				      <c:forEach items="${noanswers}" var="noanswer" varStatus="st">
						<tr>
						  <td class="col-md-1">	
							<dl>
							  <dt>${noanswer.acount}</dt>
							  <dd>回答</dd>
							</dl>
						  </td>
						  <td class="col-md-1">	
							<dl>
							  <dt>${noanswer.ccount}</dt>
							  <dd>收藏</dd>
							</dl>
						  </td>
						  <td class="col-md-8">
							<dl>
							  <dt><a href="" style="color: green; font-size: 8px;">${noanswer.uName}</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="" style="color: #0ccccc;font-size: 8px;"><fmt:formatDate value="${noanswer.qApplytime}" pattern="yyyy-MM-dd HH:mm:ss"/>提问</a></dt>
							  <dd><h4 class="title"><a href="${path}/ques/answerques/${noanswer.qId}" style="font-size: 24px;font-weight: bold;">${noanswer.qTitle}</a></dd>
							</dl>
						  </td>
						</tr>
					  </c:forEach>
				  </table>
					
				</div>
			</div>
			<div class="tab-pane fade" id="isok">
				<div class="container">           
			      <table class="table"  style="width:70% height:20px ">
				      <c:forEach items="${yesanswers}" var="yesanswer" varStatus="st">
						<tr>
						  <td class="col-md-1">	
							<dl>
							  <dt>${yesanswer.acount}</dt>
							  <dd>回答</dd>
							</dl>
						  </td>
						  <td class="col-md-1">	
							<dl>
							  <dt>${yesanswer.ccount}</dt>
							  <dd>收藏</dd>
							</dl>
						  </td>
						  <td class="col-md-8">
							<dl>
							  <dt><a href="" style="color: green; font-size: 8px;">${yesanswer.uName}</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="" style="color: #0ccccc;font-size: 8px;"><fmt:formatDate value="${yesanswer.qApplytime}" pattern="yyyy-MM-dd HH:mm:ss"/>提问</a></dt>
							  <dd><h4 class="title"><a href="${path}/ques/answerques/${yesanswer.qId}" style="font-size: 24px;font-weight: bold;">${yesanswer.qTitle}</a></dd>
							</dl>
						  </td>
						</tr>
					  </c:forEach>
				  </table>
				  	
				</div>
			</div>
		</div>
	</div>
	<script type="text/javascript">
		function tques(){
			$.ajax({
				cache : true,
   				type : "POST",
   				url : "<c:url value='/login/askquestion'/>",
   				error : function(
   						request){
   					return;
   				},
   				success : function(data){
   					if(data=="0"){
   						alert("只有登录后才能提问。请登录！");
   					}else{
   						window.location.href="askques";
   					}
   				}
			});
		}
	</script>
</body>
</html>